- dashboard = local_assigns[:dashboard]
- custom_dom_id = dom_id(milestone.try(:milestones) ? milestone.milestones.first : milestone)
- milestone_type = milestone.group_milestone? ? 'Group Milestone' : 'Project Milestone'

%li{ class: "milestone milestone-#{milestone.closed? ? 'closed' : 'open'}", id: custom_dom_id }
  .row
    .col-sm-6
      .append-bottom-5
        %strong= link_to truncate(milestone.title, length: 100), milestone_path
        - if @group
          = " - #{milestone_type}"

      - if @project || milestone.is_a?(GlobalMilestone) || milestone.group_milestone?
        - if milestone.due_date || milestone.start_date
          .milestone-range.append-bottom-5
            = milestone_date_range(milestone)
        %div
          = render('shared/milestone_expired', milestone: milestone)
          - if milestone.group_milestone?
            .label-badge.label-badge-blue.d-inline-block
              = milestone.group.full_name
          - if milestone.legacy_group_milestone?
            .projects
              - milestone.milestones.each do |milestone|
                = link_to milestone_path(milestone) do
                  %span.label-badge.label-badge-blue.d-inline-block.append-bottom-5
                    = dashboard ? milestone.project.full_name : milestone.project.name

    .col-sm-4.milestone-progress
      = milestone_progress_bar(milestone)
      = link_to pluralize(milestone.total_issues_count(current_user), 'Issue'), issues_path
      &middot;
      = link_to pluralize(milestone.merge_requests.size, 'Merge Request'), merge_requests_path
      .float-lg-right.light #{milestone.percent_complete(current_user)}% complete
    .col-sm-2
      .milestone-actions.d-flex.justify-content-sm-start.justify-content-md-end
        - if @project
          - if can?(current_user, :admin_milestone, milestone.project) and milestone.active?
            - if @project.group
              %button.js-promote-project-milestone-button.btn.btn-blank.btn-sm.btn-grouped.has-tooltip{ title: _('Promote to Group Milestone'),
                disabled: true,
                type: 'button',
                data: { url: promote_project_milestone_path(milestone.project, milestone),
                        milestone_title: milestone.title,
                        group_name: @project.group.name,
                        target: '#promote-milestone-modal',
                        container: 'body',
                        toggle: 'modal' } }
                = sprite_icon('level-up', size: 14)

            = link_to 'Close Milestone', project_milestone_path(@project, milestone, milestone: {state_event: :close }), method: :put, remote: true, class: "btn btn-sm btn-close btn-grouped"
          - unless milestone.active?
            = link_to 'Reopen Milestone', project_milestone_path(@project, milestone, {state_event: :activate }), method: :put, class: "btn btn-grouped btn-reopen"
        - if @group
          - if can?(current_user, :admin_milestone, @group)
            - if milestone.closed?
              = link_to 'Reopen Milestone', group_milestone_route(milestone, {state_event: :activate }), method: :put, class: "btn btn-sm btn-grouped btn-reopen"
            - else
              = link_to 'Close Milestone', group_milestone_route(milestone, {state_event: :close }), method: :put, class: "btn btn-sm btn-grouped btn-close"
        - if dashboard
          .status-box.status-box-milestone
            = milestone_type
